package com.cheyun.netsalev3.view

import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProviders
import com.cheyun.netsalev3.R
import com.cheyun.netsalev3.adapter.HomePageAdapter
import com.cheyun.netsalev3.databinding.ActivitySearchResultBinding
import com.cheyun.netsalev3.utils.BaseActivity
import com.cheyun.netsalev3.utils.InjectorUtils
import com.cheyun.netsalev3.view.home.CustomerItemFragment
import com.cheyun.netsalev3.viewmodel.CustomerItemFragmentViewModel

class SearchResultActivity : BaseActivity<ActivitySearchResultBinding>() {
    override fun initContentView(): Int {
        return R.layout.activity_search_result
    }

    private var listFragmet = ArrayList<Fragment>()
    var nkey = ""
    var hashMap = HashMap<String, String>()
    override fun initViewModel(): ViewModel? {

        intent.getStringExtra("nkey")?.apply {
            nkey = this
        }
        var nkeys = arrayListOf(
                nkey
        )
        intent.getSerializableExtra("hashMap")?.apply {
            hashMap = this as HashMap<String, String>
        }
        val factory = InjectorUtils.getCustomerItemFragmentViewModelFactory(nkeys, hashMap)
        return ViewModelProviders.of(this, factory).get(CustomerItemFragmentViewModel::class.java)
    }

    override fun initView() {
        listFragmet.add(CustomerItemFragment.newInstance(nkey))
        val pagerAdapter = HomePageAdapter(supportFragmentManager, listFragmet)
        binding.viewPager.adapter = pagerAdapter
    }

    override fun initData() {
    }


}
